home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 7: Sunsite / Linux Cubed Series 7 - Sunsite Vol 1.iso / system / shells / kiss-0.11 / kiss-0 / kiss / src / setexpandedstring.c < prev    next >
C/C++ Source or Header  |  1995-03-23  |  632b  |  33 lines

  1. #include "kiss.h"
  2.  
  3. Stringstack setexpandedstring (char *s)
  4. {
  5.     glob_t
  6.     globres;
  7.     register int
  8.     i;
  9.     Stringstack
  10.     ret;
  11.  
  12.     /* no wildcards? just a string. */
  13.     if (! strchr (s, '*') && ! strchr (s, '?'))
  14.     return (setstring (s));
  15.  
  16.     /* initialize retval */
  17.     ret.nstr = 0;
  18.     ret.str = NULL;
  19.  
  20.     if (glob (s, GLOB_NOCHECK, NULL, &globres))
  21.     warning ("file globbing failure");
  22.     else
  23.     {
  24.     ret.nstr = globres.gl_pathc;
  25.     ret.str = xmalloc ( (ret.nstr + 1) * sizeof (char *) );
  26.     for (i = 0; i < globres.gl_pathc; i++)
  27.         ret.str [i] = xstrdup (globres.gl_pathv [i]);
  28.     globfree (&globres);
  29.     }
  30.  
  31.     return (ret);
  32. }
  33.